Ask Your Question
0

How to check E drive exits or not in windows

asked 2015-05-25 04:41:19 -0500

Kiran gravatar image

updated 2015-05-26 15:56:53 -0500

I want to install software in E drive. How to verify whether e drive exist or not ?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-05-26 15:56:03 -0500

I would suggest using a custom fact that determines where to install the software. That will be Ruby and you can just test the existence of the drive.

The idea is that you would provide something like software_drive, with a value of E:\ if it exists and C:\ (or %SystemDrive%) if is doesn't.

edit flag offensive delete link more
0

answered 2015-05-27 06:54:38 -0500

millerjl1701 gravatar image

updated 2015-05-27 07:39:34 -0500

One can use an exec statement with an onlyif attribute and a creates attribute so that the exec only runs once.

Example code in H:\test.pp checking for H:. (Modification for use with msiexec and E: is left to the reader as an exercise... :)

exec { 'test':
  command => 'C:\Windows\System32\cmd.exe /c "mkdir H:\hello_world"',
  onlyif  => 'C:\Windows\System32\cmd.exe /c "if exist H:\ (exit 0) else (exit 1)"',
  creates => 'H:\hello_world',
}

which results in the following output:

PS H:\> dir | Select-String -pattern hello

test.pp:2:  command => 'C:\Windows\System32\cmd.exe /c "mkdir H:\hello_world"',
test.pp:4:  creates => 'H:\hello_world',


PS H:\> puppet apply H:\test.pp
Notice: Compiled catalog for flywheel.iowa.uiowa.edu in environment production in 0.51 seconds
Notice: /Stage[main]/Main/Exec[test]/returns: executed successfully
Notice: Finished catalog run in 2.19 seconds
PS H:\> dir | Select-String -pattern hello

hello_world
test.pp:2:  command => 'C:\Windows\System32\cmd.exe /c "mkdir H:\hello_world"',
test.pp:4:  creates => 'H:\hello_world',


PS H:\> puppet apply .\test.pp
Notice: Compiled catalog for flywheel.iowa.uiowa.edu in environment production in 0.56 seconds
Notice: Finished catalog run in 0.15 seconds
PS H:\>
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-05-25 04:41:19 -0500

Seen: 485 times

Last updated: May 27 '15